package com.yiyi.credit.manage.sso.api.controller;


import com.yiyi.credit.manage.sso.model.dto.response.Response;
import com.yiyi.credit.manage.sso.model.entity.SysRole;
import com.yiyi.credit.manage.sso.service.inner.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RefreshScope
@RestController
@RequestMapping("system/role")
public class RoleController {

    @Autowired
    SysRoleService sysRoleService;



    @PostMapping(value = "/getSysRoleList")
    public Object getSysRoleList(Long sysInfoId) throws Exception {
        return new Response<>(sysRoleService.getSysRoleList(sysInfoId));
    }



    @PostMapping(value = "/addSysRole")
    public Object addSysRole(Long sysInfoId,String roleName) throws Exception {

        SysRole sysRole=new SysRole();
        sysRole.setSysId(sysInfoId);
        sysRole.setRoleName(roleName);

        //增加角色表
        sysRoleService.addSysRole(sysRole);
        return new Response<>();
    }
}